import { EventKey } from "../common/Key";
import { GameData } from "../game/GameData";

cc.Class({
    extends: cc.Component,

    properties: {
        labDiamond: cc.Label,
    },

    onLoad() {
        G.onFire.on(EventKey.EVENT_UPDATE_DIAMOND, this._onFire, this);
        this.node.on('click', () => {
            if(GameData.getCanGetShareDiamond()){
                G.ui.openUI('PanelAddDiamond')
            }else{
                G.game.toast('今日免费钻石次数已达上限', 1);
            }

        }, this)
    },
    onDestroy() {
        G.onFire.off(EventKey.EVENT_UPDATE_DIAMOND, this._onFire, this);
    },
    _onFire() {
        this._updataDiamond();
    },
    onEnable() {
        this._updataDiamond();
    },
    _updataDiamond() {
        this.labDiamond.string = GameData.getDiamond();
    },
    // update (dt) {},
});
